package com.yuejian.neusoft.yuejian_24.fragment;

import android.content.Context;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.yuejian.neusoft.yuejian_24.R;
import com.yuejian.neusoft.yuejian_24.adapter.ClassListAdapter;
import com.yuejian.neusoft.yuejian_24.javaBean.Class;
import com.yuejian.neusoft.yuejian_24.listener.ListListener;
import com.yuejian.neusoft.yuejian_24.model.ClassModel;

import java.util.List;

public class MasterClassFragment extends Fragment {
    private View view=null;
    private SharedPreferences sp;
    private RecyclerView recyclerview;

    ListListener<Class> listener = new ListListener<Class>() {
        @Override
        public void onResponse(List<Class> t) {
            recyclerview.setAdapter(new ClassListAdapter(getContext(),t));
        }

        @Override
        public void onFail() {

        }
    };

    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container,
                             Bundle savedInstanceState)
    {
        view=inflater.inflate(R.layout.fragment_master_class, container, false);
        recyclerview = (RecyclerView)view.findViewById(R.id.rv_class);
        recyclerview.setLayoutManager(new LinearLayoutManager(this.getActivity()));
        sp = getActivity().getSharedPreferences("userinfo", Context.MODE_PRIVATE);
        ClassModel classModel = new ClassModel();
        classModel.classlist(sp.getString("mid",""),listener);
        return view;
    }
}
